
//
//  UIBarButton+Extension.swift
//  CLWeibo
//
//  Created by 陈亮 on 16/7/9.
//  Copyright © 2016年 陈亮. All rights reserved.
//

import UIKit
//分类不能提供指定构造函数 不能定义储存属性
extension UIBarButtonItem{
    
    //提供便利构造函数 创建UIBarButtonItem
    convenience init(title :String,target :AnyObject?,action :Selector) {
        self.init()
        let button = UIButton()
        //设置按钮点击事件
        button.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        button.setTitle(title, forState:.Normal)
        button.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        button.setTitleColor(UIColor.orangeColor(), forState: .Highlighted)
        button.titleLabel?.font = UIFont.systemFontOfSize(15)
        button.sizeToFit()
        customView = button 
    }
}
